package main

import "fmt"

func main() {
	student := Student{"张三", 1}
	fmt.Println(student)
	fmt.Printf("name is:%s, gender is:%d\n", student.Name, student.Gender)
	changeStudent(&student)
	fmt.Println(student)

	student.changeStudentName("wangwu")
	fmt.Println("3.", student)
}

// 定义student结构体
type Student struct {
	Name string
	Gender int32
}

// 结构体是按值传递
func changeStudent(stu *Student) {
	stu.Name = "lisi"
}

// 方法
func (stu *Student) changeStudentName(name string)  {
	stu.Name = name
}